#pragma execution_character_set("utf-8")
#include "config_item_widget.h"

ConfigItemWidget::ConfigItemWidget(QWidget *parent)
    : QWidget(parent)
    , m_mainLayout(new QHBoxLayout())
    , m_labTitle(new QLabel())
     , m_labMax(new QLabel())
     , m_labMin(new QLabel())
     , m_edtMax(new QLineEdit())
     , m_edtMin(new QLineEdit())

{
    m_mainLayout->addWidget(m_labTitle);
    m_mainLayout->addWidget(m_labMin);
    m_mainLayout->addWidget(m_edtMin);
    m_mainLayout->addWidget(m_labMax);
    m_mainLayout->addWidget(m_edtMax);
    m_mainLayout->addStretch();
    setLayout(m_mainLayout);
}

void ConfigItemWidget::setData(QString strTitle, QString strMin, int iMin, QString strMax, int iMax)
{
    m_labTitle->setText(strTitle);
    m_labMin->setText(strMin);
    m_edtMin->setText(QString::number(iMin));
    m_labMax->setText(strMax);
    m_edtMax->setText(QString::number(iMax));
}

ConfigItem ConfigItemWidget::getData()
{
        ConfigItem res;
        res.strTitle = m_labTitle->text();
        res.iMin = m_edtMin->text().toInt();
        res.iMax = m_edtMax->text().toInt();
        res.strMax = m_labMax->text();
        res.strMin = m_labMin->text();
        return res;
}
